FROM hub.gitee-ai.com/gitee-ai-internal/node:18 AS base

# Install dependencies only when needed
FROM base AS deps
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache libc6-compat
COPY --link package.json yarn.lock .yarnrc /app/
WORKDIR /app
RUN yarn config set registry https://registry.npmmirror.com
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps --link /app /app
COPY --link . /app
RUN yarn build

# Serve with `docusaurus serve`.
FROM base AS runner
WORKDIR /app
COPY --from=builder --link /app /app
EXPOSE 3000
CMD ["yarn", "serve", "--host", "0.0.0.0", "--no-open"]
